﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Utilities
{
    /// <summary>
    /// Helper classes for dealing with directories...
    /// </summary>
    public static class DirectoryHelpers
    {
        /// <summary>
        /// Sets or unsets the index bit on the file -- this is the bit that controls if we are going to
        /// allow the search guy to do the indexing.
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="enableIndexing"></param>
        public static void SetIndexStatus(this DirectoryInfo dir, bool enableIndexing)
        {
            FileAttributes attrib = dir.Attributes;
            if (enableIndexing)
            {
                attrib = attrib & (~FileAttributes.NotContentIndexed);
            }
            else
            {
                attrib = attrib | FileAttributes.NotContentIndexed;
            }
            dir.Attributes = attrib;
        }
    }
}
